#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
default_encoding="utf-8"
if(default_encoding!=sys.getdefaultencoding()):
    reload(sys)
    sys.setdefaultencoding(default_encoding)

class file(object):

    def write(self,data,file="e:/test.sql"):

        # 打开一个文件
        try:
            fo = open(file, "w+")
            fo.write(data)
        except IOError:
            message = u"写入文件失败: 没有权限或文件不存在!"
            return False, message
        else:
            message = u"备份成功"
            fo.close()
            return True, message







if __name__ == "__main__":
    f = file()
    f.write("d:/a.sql", "afasdhfakdfaksdfadf\naddf")